package com.hex.ds.hdrs.warn.controller;

import com.hex.bigdata.hbda.base.Page;
import com.hex.ds.hdrs.common.page.PageData;
import com.hex.ds.hdrs.warn.po.WarnSendLog;
import com.hex.ds.hdrs.warn.service.WarnSendLogService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Package: com.hex.ds.hdrs.warn.controller
 * @ClassName WarnSendLogController
 * @Description: 告警发送日志控制器
 * @Author: ji.tang
 * @Date 2022/9/2 9:24
 * @Version v1.0
 **/
@RestController
@RequestMapping("/api/warnSendLog")
@Slf4j
@ApiOperation("告警发送日志")
public class WarnSendLogController {

    @Autowired
    private WarnSendLogService warnSendLogService;

    /**
     * @Method: select
     * @Param: [warnConf, page]
     * @Return: org.springframework.http.ResponseEntity
     * @Description: 分页查询告警发送日志
     * @Author: ji.tang
     * @Date: 2022/9/2 9:27
     * @Version: V1.0
     */
    @ApiOperation("分页查询告警发送日志")
    @GetMapping("/selectPages")
    public ResponseEntity select(WarnSendLog warnSendLog, Page page) {
        log.debug("进入了【WarnSendLogController】的select方法");
        PageData pageData = new PageData(this.warnSendLogService.selectPages(warnSendLog, page), page);
        return new ResponseEntity(pageData, HttpStatus.OK);
    }

    /**
     * @Method: add
     * @Param: [warnSendLog]
     * @Return: org.springframework.http.ResponseEntity<java.lang.Object>
     * @Description: 添加告警日志信息
     * @Author: ji.tang
     * @Date: 2022/9/2 13:40
     * @Version: V1.0
     */
    @ApiOperation("添加告警日志信息")
    @PostMapping("/insert")
    public ResponseEntity<Object> insert(@RequestBody WarnSendLog warnSendLog) {
        log.debug("添加告警配置【WarnSendLogController.add】warnSendLog【{}】", warnSendLog);
        this.warnSendLogService.insert(warnSendLog);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
